package org.taobao.ibatiside.ui.binding;

import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;

public class EmptyValidator implements IValidator {
	private final String proptyName;
	
	public EmptyValidator(String proptyName) {
		super();
		this.proptyName = proptyName;
	}

	@Override
	public IStatus validate(Object value) {
		if (value == null || (value instanceof String && ((String)value).trim().length() == 0)){
			return ValidationStatus.error(proptyName+" does not set!");
		}
		return ValidationStatus.OK_STATUS;
	}

}
